package com.sqx.modules.sign.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.sign.entity.TbSignin;
import com.sqx.modules.sign.service.TbSignInService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description：TODO
 * @author： qiao
 * @create： 2024/7/5 10:41
 */
@RestController
@RequestMapping("/app/tbSignIn")
@Api(value = "签到相关-用户端", tags = {"签到相关-用户端"})
public class TbSignInController {

    @Autowired
    private TbSignInService tbSigninService;

    @Login
    @ApiOperation("用户签到")
    @PostMapping("/signin")
    public Result signin(@ApiParam("签到实体") TbSignin tbSignin,@ApiParam("用户id") @RequestAttribute("userId") Long userId) {
        tbSignin.setUserId(userId);
        return tbSigninService.signIn(tbSignin);
    }

    @Login
    @ApiOperation("获取用户签到列表")
    @PostMapping("/getSigninList")
    public Result getSigninList(@ApiParam("用户id")@RequestAttribute("userId") Long userId) {
        return tbSigninService.getSignInList(userId);
    }

    @Login
    @ApiOperation("获取金币获得的明细列表")
    @PostMapping("/getListByRecords")
    public Result getListByRecords(@ApiParam("页码")@RequestParam(value = "pageNum")Integer pageNum,
                                   @ApiParam("条数")@RequestParam(value = "pageSize")Integer pageSize,
                                   @ApiParam("用户id")@RequestAttribute(value = "userId") Long userId) {
        return tbSigninService.getListByRecords(pageNum,pageSize,userId);
    }


    @ApiOperation("获取签到对应的金币数量表")
    @GetMapping("/getSignInRewards")
    public Result getSignInRewards() {
        return tbSigninService.getSignInRewards();
    }
}
